package org.ndky.fallback;

import org.ndky.remoteService.ProviderServiceRM;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class FallbackRemoteCall implements FallbackFactory<ProviderServiceRM> {
    private static final Logger log = LoggerFactory.getLogger(FallbackRemoteCall.class);

    @Override
    public ProviderServiceRM create(Throwable throwable)
    {
        log.error("用户服务Provider 调用失败:{}", throwable.getMessage());
        return new ProviderServiceRM()
        {
            @Override
            public String hello()
            {
                return "获取Provider Hello 失败:" + throwable.getMessage();
            }
        };
    }
}
